Skip to content

feat(MediaMtx): add MediaMtxPlayer component for WebRTC preview - #1408

Merged
ArgoZhang merged 10 commits into
masterfrom
feat-new
Dec 3, 2026
Merged

ArgoZhang merged 10 commits into
masterfrom
feat-new

Conversation

@ArgoZhang

@ArgoZhang ArgoZhang commented Dec 3, 2026 •

Copy link
Copy Markdown
Member

Link issues

fixes #1407

Summary By Copilot

  • 新增 MediaMtxPlayer 组件,在首次交互渲染时启动 MediaMTX 网关并登记摄像头,成功后以 iframe 展示 WebRTC 预览页面。
  • 提供加载中、未配置、工具缺失、网关启动失败、登记失败与非法地址等状态的本地化提示,新增 Title 与 IsMuted 参数。
  • BootstrapBlazor.MediaMtx 切换为 Microsoft.NET.Sdk.Razor,内嵌 en/zh 本地化资源,版本更新为 11.0.5。
  • 更新 README.MediaMtx.md 示例为 MediaMtxPlayer,并为 HikVision 包补充 PackageReadmeFile 元数据。

Regression?

  • Yes
  • No

Risk

  • High
  • Medium
  • Low

新增组件,不修改现有公开 API 与行为;主要变更集中在 MediaMtx 包的项目配置和本地化资源。

Verification

  • Manual (required)
  • Automated

本流程仅创建 Issue 与 PR,未运行构建或测试。建议合并前按改动范围执行 dotnet build src/components/BootstrapBlazor.MediaMtx -f net11.0 并在示例中手工验证预览流程。

Packaging changes reviewed?

  • Yes
  • No
  • N/A

包版本更新为 11.0.5,切换 Razor SDK 并内嵌 Locales/*.json,同时更新包 README 示例。

☑️ Self Check before Merge

⚠️ Please check all items below before review. ⚠️

  • Doc is updated/provided or not needed
  • Demo is updated/provided or not needed
  • Merge the latest code from the main branch

Summary by Sourcery

Provide a built-in MediaMTX WebRTC preview component and align gateway management and package guidance with its behavior.

New Features:

  • Add a MediaMtxPlayer component that starts the MediaMTX gateway, registers a camera, and embeds its WebRTC preview, with localized status messages and configurable title and mute behavior.

Enhancements:

  • Change gateway reuse to detect an available local Control API using the configured password, and avoid automatically replacing a running gateway when configuration changes.
  • Remove the custom camera playback URL option; playback URLs are now derived from the configured public base URL or local address and camera path.
  • Move MediaMTX service, model, and launcher files into Services and Extensions directories.

Build:

  • Switch the MediaMTX project to the Razor SDK and update package metadata, including the HikVision package README metadata.

Documentation:

  • Update the MediaMTX README and skill guide with the player component, revised gateway reuse behavior, and removal of the custom playback URL option.

Chores:

  • Add English and Chinese localization resource files for the player component.

@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026

Copy link
Copy Markdown

Sorry @ArgoZhang, you've used your own review budget of 250,000 diff characters for the last 7 days.

You can request another review in 5 minutes by commenting @sourcery-ai review. Upgrade to get a review now.

@bb-auto bb-auto Bot added the enhancement New feature or request label Dec 3, 2026
@bb-auto bb-auto Bot added this to the v11.0.0 milestone Dec 3, 2026
bb-auto[bot]
bb-auto Bot previously approved these changes Dec 3, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

bb-auto[bot]
bb-auto Bot previously approved these changes Dec 3, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Move unchanged MediaMTX service implementation, launcher, configuration, and exception files into their new folders.

  • src/components/BootstrapBlazor.MediaMtx/Services/IMediaMtxProcessLauncher.cs
  • src/components/BootstrapBlazor.MediaMtx/Services/MediaMtxProcessLauncher.cs
  • src/components/BootstrapBlazor.MediaMtx/Services/MediaMtxToolNotFoundException.cs
  • src/components/BootstrapBlazor.MediaMtx/Services/MediaMtxWebRtcConfiguration.cs

UI

Add the MediaMtxPlayer component and its initialization, registration, URL validation, mute handling, and localized rendering states.

  • src/components/BootstrapBlazor.MediaMtx/Components/MediaMtxPlayer.razor L1-40
  • src/components/BootstrapBlazor.MediaMtx/Components/MediaMtxPlayer.razor.cs L1-184

Add English and Chinese strings for the player's loading, configuration, and failure states.

  • src/components/BootstrapBlazor.MediaMtx/Locales/en.json L1-11
  • src/components/BootstrapBlazor.MediaMtx/Locales/zh.json L1-11

Configuration

Update package and Razor project configuration for the MediaMTX component and add the HikVision package README metadata.

  • src/components/BootstrapBlazor.HikVision/BootstrapBlazor.HikVision.csproj L11
  • src/components/BootstrapBlazor.MediaMtx/BootstrapBlazor.MediaMtx.csproj L1-4, L22-26
  • src/components/BootstrapBlazor.MediaMtx/_Imports.razor L1

Move unchanged HTTP client and service-registration extensions into the Extensions folder.

  • src/components/BootstrapBlazor.MediaMtx/Extensions/HttpClientExtensions.cs
  • src/components/BootstrapBlazor.MediaMtx/Extensions/MediaMtxServiceCollectionExtensions.cs

Documentation

Update the package README with the component usage, generated playback URL behavior, and revised gateway reuse semantics.

  • src/components/BootstrapBlazor.MediaMtx/README.MediaMtx.md L168-177 (+6 small edits)

Document component rendering and updated gateway and playback configuration guidance in the MediaMTX skill guide.

  • src/components/BootstrapBlazor.MediaMtx/skills/bb-mediamtx/SKILL.md L40-43, L49-55 (+2 small edits)

Other changes

Files not grouped.

  • src/components/BootstrapBlazor.MediaMtx/IMediaMtxService.cs L18-19, L37-38
  • src/components/BootstrapBlazor.MediaMtx/MediaMtxOptions.cs L32-33
  • src/components/BootstrapBlazor.MediaMtx/MediaMtxService.Gateway.cs L137-161, L231-261 (+6 small edits)
  • src/components/BootstrapBlazor.MediaMtx/MediaMtxService.cs L51-55
  • src/components/BootstrapBlazor.MediaMtx/MediaMtxCameraOptions.cs L22 (removed lines)
  • src/components/BootstrapBlazor.MediaMtx/MediaMtxSharedGateway.cs L10 (removed lines), L15 (removed lines), L86 (removed lines)

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai

sourcery-ai Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

Linked issues

Checked at commit c3116a0

#1407 feat(MediaMtx): add MediaMtxPlayer component for WebRTC preview · 6 of 6 met

# Requirement Status Notes
1 Add MediaMtxPlayer with MediaMtxCameraOptions and start the gateway, then register the camera on first interactive render. ✅ Met The component runs EnsureStartedAsync and then AddOrUpdateAsync from OnAfterRenderAsync on the first render.
2 Render the MediaMTX player page in an iframe once registration succeeds. ✅ Met The component renders an iframe when the registered URL is valid; it shows an error state instead when registration returns no usable URL.
3 Show localized loading, missing-configuration, missing-tool, gateway-start, and registration-failure states. ✅ Met The component uses localized messages for each state, with a path-aware missing-tool message when available.
4 Support Title and IsMuted parameters, with the default mute option preserving the original player URL. ✅ Met Title is used on the iframe; IsMuted defaults to true and returns the registered URL unchanged.
5 Provide embedded English and Chinese localization resources and update package documentation. ✅ Met The project embeds Locales/*.json, and the README and skill guide document the player.
6 Do not download the MediaMTX tool or re-register when Options changes after the first render. ✅ Met The component only calls the service on first render; its API documentation says the tool must be deployed separately and later option changes do not re-register.

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New gaps against the linked issues

bb-auto[bot]
bb-auto Bot previously approved these changes Dec 3, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

bb-auto[bot]
bb-auto Bot previously approved these changes Dec 3, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

bb-auto[bot]
bb-auto Bot previously approved these changes Dec 3, 2026

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

移除 MediaMtxCameraOptions.PlayUrl,播放地址统一由 WebRtc.PublicUrl 或
回环地址与 Path 生成,并同步更新播放器、服务接口与文档。

@bb-auto bb-auto Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto approved by bb-auto

@ArgoZhang
ArgoZhang merged commit e64e526 into master Dec 3, 2026
3 checks passed
@ArgoZhang
ArgoZhang deleted the feat-new branch December 3, 2026 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(MediaMtx): add MediaMtxPlayer component for WebRTC preview

1 participant